<template>
    <div class="user">
        <commonUserinfo :userInfoData="{userItemIndex:itemIndex,userLeftHeight:userLeftHeight,$parent:$parent}">
            <div id="applyInfo" class="user_main_right f_left text_center" ref="userRightH">
                <div class="user_userInfo apply_info color666" v-if="showApplyInfo" :class="applyLsts?'applyOne':'applyMore'">
                    <div v-for="(item,index) in applyLst" :key="index">
                        <h3>继续教育</h3>
                        <div class="apply_info_item">
                            <dl>
                                <dt class="f_left">姓名：</dt>
                                <dd class="f_left">{{item.realName}}</dd>
                            </dl>
                            <dl>
                                <dt class="f_left">专业：</dt>
                                <dd class="f_left">{{item.typeName}}</dd>
                            </dl>
                            <!-- <dl>
								<dt class="f_left">证书：</dt>
								<dd class="f_left">{{item.typeName}}作业证书</dd>
							</dl> -->
                            <a class="apply_info_btn" target="_blank" @click="lookCertificate(item.diplomaUrl)">查看证书</a>
                        </div>
                    </div>
                </div>
                <!-- 没有报名信息-->
                <div class="user_userInfo apply_info apply_info_no_list color666" v-if="!showApplyInfo">
                    <h3>证书信息</h3>
                    <div class="apply_info_item">
                        <img src="/static/img/user/noimformation_02.png">
                        <p>
                            抱歉您当前没有证书信息~<br>
                        </p>
                    </div>
                </div>
            </div>
        </commonUserinfo>
    </div>
</template>

<script>
    import commonUserinfo from '../../../components/cont_education/c_userinfo.vue'
    export default {
        name: "apply_info",
        data: function() {
            return {
                applyLsts: true,
                itemIndex: 4,
                userLeftHeight: '',
                showApplyInfo: true,
                applyLst: [],
            }
        },
        mounted: function() {
            var that = this;
            this.showApplyInfo = false;
            this.common.post(this.api.getMyCertificate, {}, function(res) {
                that.applyLst = res.resultMap;
                that.showApplyInfo = res.resultMap.length > 0;
                setTimeout(function() {
                    that.userLeftHeight = that.$refs.userRightH.offsetHeight - 2 + "px";
                }, 10);

                if (that.applyLst.length == 0) {
                    that.showApplyInfo = false;
                } else {
                    if (that.applyLst.length == 1) {
                        that.applyLsts = true;
                    } else if (that.applyLst.length > 1) {
                        that.applyLsts = false;
                    }
                    that.showApplyInfo = true;
                }
            });
        },
        methods: {
            lookCertificate: function(diplomaUrl) {
                window.open(diplomaUrl);
                // window.location.href = diplomaUrl;
            }
        },
        components: {
            commonUserinfo
        }
    }
</script>

<style>
</style>
